package com.ruoyi.basedocument.service.impl;

import java.util.List;

import com.ruoyi.basedocument.domain.BomBaseunit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.basedocument.mapper.BomCategoryMapper;
import com.ruoyi.basedocument.domain.BomCategory;
import com.ruoyi.basedocument.service.IBomCategoryService;

/**
 * 类别Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-09-13
 */
@Service
public class BomCategoryServiceImpl implements IBomCategoryService 
{
    @Autowired
    private BomCategoryMapper bomCategoryMapper;

    /**
     * 查询类别
     * 
     * @param id 类别主键
     * @return 类别
     */
    @Override
    public BomCategory selectBomCategoryById(String id)
    {
        return bomCategoryMapper.selectBomCategoryById(id);
    }

    /**
     * 查询类别列表
     * 
     * @param bomCategory 类别
     * @return 类别
     */
    @Override
    public List<BomCategory> selectBomCategoryList(BomCategory bomCategory)
    {
        return bomCategoryMapper.selectBomCategoryList(bomCategory);
    }

    /**
     * 查询类别列表
     *
     * @param bomCategory 类别
     * @return 类别
     */
    @Override
    public List<BomCategory> selectBomCategoryList2(BomCategory bomCategory)
    {
        return bomCategoryMapper.selectBomCategoryList2(bomCategory);
    }

    /**
     * 新增类别
     * 
     * @param bomCategory 类别
     * @return 结果
     */
    @Override
    public int insertBomCategory(BomCategory bomCategory)
    {
        BomCategory obj = new BomCategory();
        obj.setNumber(bomCategory.getNumber());
        List<BomCategory> objs = selectBomCategoryList2(obj);
        if(objs!=null&&objs.size()!=0){
            throw new RuntimeException("编码已存在:"+bomCategory.getNumber());
        }
        return bomCategoryMapper.insertBomCategory(bomCategory);
    }

    /**
     * 修改类别
     * 
     * @param bomCategory 类别
     * @return 结果
     */
    @Override
    public int updateBomCategory(BomCategory bomCategory)
    {
        return bomCategoryMapper.updateBomCategory(bomCategory);
    }

    /**
     * 批量删除类别
     * 
     * @param ids 需要删除的类别主键
     * @return 结果
     */
    @Override
    public int deleteBomCategoryByIds(String[] ids)
    {
        return bomCategoryMapper.deleteBomCategoryByIds(ids);
    }

    /**
     * 删除类别信息
     * 
     * @param id 类别主键
     * @return 结果
     */
    @Override
    public int deleteBomCategoryById(String id)
    {
        return bomCategoryMapper.deleteBomCategoryById(id);
    }
}
